local skel = fk.CreateSkill {
  name = "emo__xueren",
}

Fk:loadTranslationTable{
  ["emo__xueren"] = "血刃",
  [":emo__xueren"] = "每当你使用【杀】指定唯一目标后，你可以令目标角色摸X张牌，此【杀】伤害值+X且抵消需要的【闪】+X，此【杀】每被响应一次则伤害值-1（X为其体力值减一且至少为1）。",

  ["#emo__xueren-invoke"] = "血刃：你可以令 %dest 摸 %arg 张牌，且此【杀】伤害+%arg",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and data.card.trueName == "slash" then
      return not data.to.dead and data:isOnlyTarget(data.to)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local x = math.max(data.to.hp - 1, 1)
    if player.room:askToSkillInvoke(player, { skill_name = self.name, prompt = "#emo__xueren-invoke::"..data.to.id..":"..x}) then
      event:setCostData(self, {tos = {data.to}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local to = data.to
    local x = math.max(to.hp - 1, 1)
    to:drawCards(x, self.name)
    data.extra_data = data.extra_data or {}
    data.extra_data.emo__xueren_invoked = true
    data.additionalDamage = (data.additionalDamage or 0) + x
    data:setResponseTimes(data:getResponseTimes() + x)
  end,
})

skel:addEffect(fk.CardUsing, {
  can_refresh = function (self, event, target, player, data)
    if target == player then
      local dat = data.responseToEvent
      return dat and (dat.extra_data or Util.DummyTable).emo__xueren_invoked
    end
  end,
  on_refresh = function (self, event, target, player, data)
    local dat = data.responseToEvent
    dat.additionalDamage = (dat.additionalDamage or 0) - 1
  end,
})

return skel
